/*
package cc.chengheng.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import javax.annotation.Resource;

@Configuration
public class WebSecurityConfig权限和自定义403 extends WebSecurityConfigurerAdapter {

    @Resource
    private UserDetailsService userDetailsService;

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        // 配置没有权限访问跳转自定义页面
        http.exceptionHandling().accessDeniedPage("/unauth.html");

        http.formLogin((form) -> {
            form.loginPage("/login.html").permitAll()
                    .loginProcessingUrl("/login") // 登陆访问的路径, 随便写个地址,这个过程框架过滤器给拦截了, 就是form 表单 的action
                    .defaultSuccessUrl("/hello"); // 登陆成功之后,跳转的路径
        });


        http.authorizeRequests()
                .antMatchers("/hello").permitAll()

                // 当前路径,分配权限
                .antMatchers("/fengliulin").hasAnyAuthority("admins, admins11")

//                .antMatchers("/fengliulin").hasRole("admins, admins1")

//                .antMatchers("/fengliulin").hasAuthority("admins")

                .anyRequest().authenticated(); // 这个代码是必须的, 否则上面的fromlogin不能使用permitAll

        http.csrf().disable();
    }


}

*/
